package com.choosefine.it.basedata.controller;

import com.choosefine.it.base.BaseController;
import com.choosefine.it.base.dto.PageDTO;
import com.choosefine.it.basedata.model.ProjectInfo;
import com.choosefine.it.basedata.model.dto.FindProjectCondition;
import com.choosefine.it.basedata.model.dto.ProjectInfoSaveDTO;
import com.choosefine.it.basedata.model.dto.ProjectInfoUpdateDTO;
import com.choosefine.it.basedata.model.vo.ProjectInfoNameVO;
import com.choosefine.it.basedata.model.vo.ProjectInfoVO;
import com.choosefine.it.basedata.model.vo.ProjectStartEndTimeVO;
import com.choosefine.it.basedata.model.vo.projectInfoAppVO;
import com.choosefine.it.basedata.service.ProjectInfoService;
import com.choosefine.it.common.def.CommonConstant;
import com.choosefine.it.common.def.ResultCode;
import com.choosefine.it.common.utils.DateUtils;
import com.choosefine.it.common.utils.StringUtils;
import com.choosefine.it.team.model.AuthorizationPicture;
import com.choosefine.it.team.model.dto.TeamDTO;
import com.choosefine.it.team.model.vo.TeamVO;
import com.choosefine.it.team.service.AuthorizationPictureService;
import com.choosefine.it.team.service.ItemInfoService;
import com.choosefine.it.worker.service.WorkerItemsRelationService;
import com.github.pagehelper.Page;
import io.swagger.annotations.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 工程详情相关控制层
 *
 * @author guwenwei 2016/11/16
 */
@RestController
@RequestMapping("/basedata/projectinfo")
@Api(value = "工程详情相关", description = "顾文伟")
public class ProjectController extends BaseController {
    Logger logger = LoggerFactory.getLogger(ProjectController.class);
    @Autowired
    ProjectInfoService projectinfoService;
    @Autowired
    ItemInfoService itemInfoService;
    @Autowired
    WorkerItemsRelationService workerItemsRelationService;
    @Autowired
    AuthorizationPictureService authorizationPictureService;

    /**
     * 添加工程
     *
     * @param projectinfo
     * @param
     * @return
     * @throws Exception
     */
    @ApiOperation(value = "存储工程详情", notes = "传入工程对象，存储工程相关详情信息")
    @ResponseBody
    @ApiResponses({@ApiResponse(code = ResultCode.SUCCESS_CREATED, message = "添加成功返回结果"),
            @ApiResponse(code = ResultCode.FAILED, message = "请求参数错误")})
    @RequestMapping(method = RequestMethod.POST)
    public String save(@RequestBody ProjectInfo projectinfo) throws Exception {
        String result = null;
        if (projectinfo != null) {
            projectinfo.setCtime(DateUtils.getNowTime());
            Integer num = projectinfoService.insert(projectinfo);
            if (num != null && num > 0) {
                result = responseSuccess(num, ResultCode.SUCCESS_CREATED, ResultCode.MSG_CREATE_SUCCESS);
            } else {
                result = responseFail(ResultCode.MSG_ERROR);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

    @ApiOperation(value = "修改工程详情", notes = "传入工程对象，修改工程相关详情信息")
    @ResponseBody
    @ApiResponses({@ApiResponse(code = ResultCode.SUCCESS_CREATED, message = "添加成功返回结果"),
            @ApiResponse(code = ResultCode.FAILED, message = "请求参数错误")})
    @RequestMapping(method = RequestMethod.PUT)
    public String update(@RequestBody ProjectInfo projectinfo) throws Exception {
        String result = null;
        if (projectinfo != null) {
            projectinfo.setUtime(DateUtils.getNowTime());
            Integer num = projectinfoService.update(projectinfo);
            if (num != null && num > 0) {
                result = responseSuccess(num, ResultCode.SUCCESS_CREATED, ResultCode.MSG_UPDATE_SUCCESS);
            } else {
                result = responseFail(ResultCode.MSG_ERROR);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

    @ApiOperation(value = "根据工程编号取工程详情", notes = "传入工程编号，根据编号获取相关工程详情", response = ProjectInfo.class)
    @ApiImplicitParam(name = "projectCode", value = "工程编号", required = true, dataType = "String", paramType = "path")
    @RequestMapping(value = "/projectCode/{projectCode}", method = RequestMethod.GET)
    public String getProjectByCode(@PathVariable String projectCode) throws Exception {
        String result = null;
        if (projectCode != null) {
            ProjectInfo projectinfo = projectinfoService.findByProjectCode(projectCode);
            if (projectinfo != null) {
                result = responseSuccess(projectinfo);
            } else {
                result = responseFail(ResultCode.MSG_ERROR);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

    @ApiOperation(value = "根据工程编号删除工程详情", notes = "传入工程编号，根据编号删除相关工程详情")
    @ApiImplicitParam(name = "peojectCode", value = "工程编号", required = true, dataType = "String", paramType = "path")
    @RequestMapping(value = "/peojectCode/{peojectCode}", method = RequestMethod.DELETE)
    public String deleteByProjectCode(@PathVariable String peojectCode) throws Exception {
        String result = null;
        if (peojectCode != null) {
            Map<String, Object> params = new HashMap<>();
            params.put("isValid", CommonConstant.INVALID);
            params.put("peojectCode", peojectCode);
            params.put("utime", DateUtils.getNowTime());
            Integer num = projectinfoService.deleteByProjectCode(params);
            if (num != null && num > 0) {
                result = responseSuccess(num);
            } else {
                result = responseFail(ResultCode.MSG_ERROR);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

    @ApiOperation(value = "统计工程的数量", notes = "")
    @RequestMapping(value = "/countProject", method = RequestMethod.GET)
    public String countProject() {
        Integer num = projectinfoService.countProject();
        return responseSuccess(num);
    }

    @ApiOperation(value = "获取所有项目", notes = "")
    @RequestMapping(value = "/projcet/{pageNum}/{pageSize}", method = RequestMethod.GET)
    public String getProjectList(@PathVariable Integer pageNum, @PathVariable Integer pageSize) throws Exception {
        String result = null;
        PageDTO pageDto = new PageDTO();
        pageDto.setPageNum(pageNum);
        pageDto.setPageSize(pageSize);
        Page<ProjectInfo> projectinfo = projectinfoService.selectAll(pageDto);
        result = responseArraySuccess(projectinfo, ResultCode.SUCCESS, "获取成功");
        return result;
    }

    @ApiOperation(value = "根据id获取所有项目", notes = "")
    @RequestMapping(value = "/projcet/{id}", method = RequestMethod.GET)
    public String getProjectInfoById(@PathVariable Integer id) throws Exception {
        String result = null;
        ProjectInfo projectinfo = projectinfoService.findByPrimaryKey(id);
        result = responseSuccess(projectinfo, ResultCode.SUCCESS, "获取成功");
        return result;
    }

    /**
     * @param projectCode
     * @param projectName
     * @param constructionUnit
     * @param constructUnit
     * @param projectDataStatus
     * @param pageNum
     * @param pageSize
     * @return
     * @throws Exception
     * @author panqianqin
     */
    @ApiOperation(value = "按条件获取所有项目", notes = "")
    @RequestMapping(value = "/getProjcetByCondition", method = RequestMethod.GET)
    public String selectAllByCondition(String projectCode, String projectName, String constructionUnit,
                                       String constructUnit, Integer projectDataStatus, Integer pageNum, Integer pageSize) throws Exception {
        Map<String, Object> params = new HashMap<>();
        if (projectCode != null && !"".equals(projectCode)) {
            params.put("projectCode", projectCode);
        }
        if (projectName != null && !"".equals(projectName)) {
            params.put("projectName", projectName);
        }
        if (constructionUnit != null && !"".equals(constructionUnit)) {
            params.put("constructionUnit", constructionUnit);
        }
        if (constructUnit != null && !"".equals(constructUnit)) {
            params.put("constructUnit", constructUnit);
        }
        if (projectDataStatus != null && !"".equals(projectDataStatus)) {
            params.put("projectDataStatus", projectDataStatus);
        }
        PageDTO pageDto = new PageDTO();
        pageDto.setPageNum(pageNum);
        pageDto.setPageSize(pageSize);
        Page<ProjectInfo> projectinfo = projectinfoService.selectAllByCondition(params, pageDto);
        return responseSuccess(projectinfo.toPageInfo(), ResultCode.SUCCESS, "获取成功");

    }

    /**
     * @author chenjian
     */
    @ApiOperation(value = "按条件获取所有项目(陈健)和状态管理接口共用", notes = "控制台-项目管理-项目基本资料",response = ProjectInfo.class)
    @RequestMapping(value = "/findProjectAllByCondition", method = RequestMethod.POST, produces = "application/json")
    public String findProjectAllByCondition(@RequestBody FindProjectCondition findProjectCondition) throws Exception {
        String result = null;
        Map<String, Object> params = new HashMap<>();
        if (findProjectCondition.getProjectCode() != null && !"".equals(findProjectCondition.getProjectCode().trim())) {
            params.put("projectCode", findProjectCondition.getProjectCode().trim());
        }
        if (findProjectCondition.getProjectName() != null && !"".equals(findProjectCondition.getProjectName().trim())) {
            params.put("projectName", findProjectCondition.getProjectName().trim());
        }
        if (findProjectCondition.getConstructionUnit() != null
                && !"".equals(findProjectCondition.getConstructionUnit().trim())) {
            params.put("constructionUnit", findProjectCondition.getConstructionUnit().trim());
        }
        if (findProjectCondition.getConstructUnit() != null
                && !"".equals(findProjectCondition.getConstructUnit().trim())) {
            params.put("constructUnit", findProjectCondition.getConstructUnit().trim());
        }
        if (findProjectCondition.getProjectCourse() != null) {
            params.put("projectCourse", findProjectCondition.getProjectCourse());
        }
        if (findProjectCondition.getProjectDataStatus() != null) {
            params.put("projectDataStatus", findProjectCondition.getProjectDataStatus());
        }
        PageDTO pageDto = new PageDTO();
        pageDto.setPageNum(findProjectCondition.getPageNum());
        pageDto.setPageSize(findProjectCondition.getPageSize());
        Page<ProjectInfo> projectInfoList = projectinfoService.findProjectAllByCondition(params, pageDto);

        if (projectInfoList.size() > 0) {
            result = responseSuccess(projectInfoList.toPageInfo());
        } else {
            result = responseFail(ResultCode.FAILED, ResultCode.MSG_DATA_ISEMPTY);
        }
        return result;
    }
    @ApiOperation(value = "批量修改项目数据保密状态(毛俊)", notes = "控制台-项目管理-项目基本资料")
    @ApiImplicitParams({@ApiImplicitParam(name = "idss", value = "项目Id,多个逗号隔开", required = true, dataType = "String", paramType = "path"),
            @ApiImplicitParam(name = "projectDataStatus", value = "保密状态0公开1不公开", required = true, dataType = "int", paramType = "path"),
            @ApiImplicitParam(name = "operatorCode", value = "操作员编号", required = true, dataType = "String", paramType = "path")})
    @RequestMapping(value = "/updateProjectInfoProjectDataStatus/{idss}/{projectDataStatus}/{operatorCode}", method = RequestMethod.PUT)
    public String updateRecruitmentVerifyStatus(@PathVariable String idss, @PathVariable Integer projectDataStatus, @PathVariable String operatorCode) {
        String result = null;
        String[] ids = idss.split(",");
        if (ids.length > 0 && projectDataStatus != null) {
            Map<String, Object> params = new HashMap<>();
            params.put("ids", ids);
            params.put("projectDataStatus", projectDataStatus);
            params.put("utime", DateUtils.getNowTime());
            params.put("operatorCode", operatorCode);
            int isSuccess = projectinfoService.updateProjectInfoProjectDataStatus(params);
            if (isSuccess == ids.length) {
                result = responseSuccess(isSuccess, ResultCode.MSG_UPDATE_SUCCESS);
            } else if (0 < isSuccess && isSuccess < ids.length) {
                result = responseSuccess(isSuccess, ResultCode.MSG_UPDATEPART_SUCCESS);
            } else {
                result = responseFail(ResultCode.MSG_UPDATE_FAILD);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_ERROR);
        }
        return result;
    }

    /**
     * @author chenjian
     */
    @ApiOperation(value = "批量修改项目进程状态为完工(陈健)", notes = "控制台-项目管理-项目基本资料")
    @RequestMapping(value = "/batchUpdateProjectCourse", method = RequestMethod.PUT)
    public String batchUpdateProjectCourse(@RequestParam(value = "projectIds", required = true) String projectIds)
            throws Exception {
        String result = null;
        if (projectIds != null && !"".equals(projectIds)) {
            String[] ides = projectIds.split(",");
            Map<String, Object> params = new HashMap<>();
            params.put("utime", DateUtils.getNowTime());
            params.put("ids", ides);
            Integer num = projectinfoService.batchUpdateProjectCourse(params);
            if (num != null && num > 0) {
                result = responseSuccess(num, ResultCode.SUCCESS, ResultCode.MSG_UPDATE_SUCCESS);
            } else {
                result = responseFail(ResultCode.MSG_ERROR);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

    /**
     * @author chenjian
     */
    @ApiOperation(value = "批量删除项目(陈健)", notes = "控制台-项目管理-项目基本资料")
    @RequestMapping(value = "/batchDeleteProjects", method = RequestMethod.PUT)
    public String batchDeleteProjects(@RequestParam(value = "projectIds", required = true) String projectIds)
            throws Exception {
        String result = null;
        if (projectIds != null && !"".equals(projectIds)) {
            String[] ides = projectIds.split(",");
            Map<String, Object> params = new HashMap<>();
            params.put("utime", DateUtils.getNowTime());
            params.put("ids", ides);
            Integer num = projectinfoService.batchDeleteProjects(params);
            if (num != null && num > 0) {
                result = responseSuccess(num, ResultCode.SUCCESS, ResultCode.MSG_DELETE_SUCCESS);
            } else {
                result = responseFail(ResultCode.MSG_ERROR);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

    /**
     * @author chenjian
     * @time 2016-12-12 上午11:24:13
     */
    @ApiOperation(value = "控制台存储工程项目(陈健)", notes = "控制台-项目管理-项目基本资料")
    @ResponseBody
    @RequestMapping(value = "/saveProjectInfo", method = RequestMethod.POST)
    public String saveProjectInfo(@RequestBody ProjectInfoSaveDTO projectInfoSaveDTO) throws Exception {
        String result = null;
        if (projectInfoSaveDTO != null) {
            String projectCode = projectinfoService.saveProjectInfo(projectInfoSaveDTO);
            if (projectCode != null && !"".equals(projectCode)) {
                result = responseSuccess(projectCode, ResultCode.SUCCESS_CREATED, ResultCode.MSG_CREATE_SUCCESS);
            } else {
                result = responseFail(ResultCode.MSG_ERROR);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

    /**
     * @author chenjian
     * @time 2016-12-14 上午10:44:27
     */
    @ApiOperation(value = "修改项目信息(陈健)", notes = "控制台-项目管理-项目基本资料")
    @RequestMapping(method = RequestMethod.POST, value = "/updateProject")
    public String updateProject(@RequestBody ProjectInfoUpdateDTO projectInfoUpdateDTO) throws Exception {
        String result = null;
        if (projectInfoUpdateDTO != null) {
            Integer num = projectinfoService.updateProjectInfo(projectInfoUpdateDTO);
            if (num != null && num > 0) {
                result = responseSuccess(num, ResultCode.SUCCESS_CREATED, ResultCode.MSG_UPDATE_SUCCESS);
            } else {
                result = responseFail(ResultCode.MSG_ERROR);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

    /**
     * @Description：项目的班组信息
     * @Author：chenjian
     * @Create Date：2017年2月15日
     * @param：
     * @return：
     */
    @ApiOperation(value = "项目的班组信息(陈健)", notes = "控制台-项目管理-项目基本资料", response = TeamVO.class)
    @RequestMapping(method = RequestMethod.POST, value = "/team/queryTeamList")
    public String queryTeamList(@RequestBody TeamDTO teamDTO) throws Exception {
        String result = null;
        teamDTO.setIsValid(CommonConstant.VALID);
        Page<TeamVO> list = itemInfoService.queryTeamList(teamDTO);
        if (list.size() > 0) {
            result = responseSuccess(list.toPageInfo());
        } else {
            result = responseFail(ResultCode.MSG_DATA_ISEMPTY);
        }
        return result;
    }

    @ApiOperation("项目经理管理的项目")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "userCode", dataType = "String", required = true, value = "用户code"),})
    @RequestMapping(value = "/findProjectConstructionUnitByManager/{userCode}", method = RequestMethod.GET)
    public String findProjectInfoByManager(@PathVariable("userCode") String userCode) {
        String result = null;
        if (userCode != null && !"".equals(userCode)) {
            List<ProjectInfo> projectInfoList = new ArrayList<>();
            List<String> constructionUnitList = new ArrayList<String>();
            // 用户code查询项目
            projectInfoList = projectinfoService.findProjectInfoByManager(userCode);
            for (ProjectInfo p : projectInfoList) {
                String constructionUnit = p.getConstructionUnit();
                constructionUnitList.add(constructionUnit);
            }
            result = responseArraySuccess(constructionUnitList, ResultCode.SUCCESS, ResultCode.MSG_SUCCESS);
        }
        return result;
    }

    /**
     * @author chenjian
     * @time 2016-12-21 下午4:20:42
     */
    @ApiOperation(value = "根据工程编号查询工程详情(陈健)", notes = "控制台-项目管理-项目基本资料", response = ProjectInfoVO.class)
    @ApiImplicitParam(name = "projcetCode", value = "工程项目编号", required = true, dataType = "String", paramType = "path")
    @RequestMapping(value = "/findProjectByCode/{projcetCode}", method = RequestMethod.GET)
    public String findProjectByCode(@PathVariable String projcetCode) throws Exception {
        String result = null;
        if (projcetCode != null) {
            ProjectInfoVO projectinfoVO = projectinfoService.queryByProjectCode(projcetCode);
            if (projectinfoVO != null && projectinfoVO.getId() != null) {
                //查询项目承包人授权书
                AuthorizationPicture authorizationPictureProject = new AuthorizationPicture();
                authorizationPictureProject.setItemId(projectinfoVO.getId());
                authorizationPictureProject.setItemType(1);
                authorizationPictureProject.setType(1);
                List<String> contractorAuthorizationList = authorizationPictureService.findPictureByItemId(authorizationPictureProject);
                if (contractorAuthorizationList.size() > 0) {
                    projectinfoVO.setContractorAuthorizationList(contractorAuthorizationList);
                }
                //查询承建单位授权书
                AuthorizationPicture authorizationPictureCompany = new AuthorizationPicture();
                authorizationPictureCompany.setItemId(projectinfoVO.getId());
                authorizationPictureCompany.setItemType(1);
                authorizationPictureCompany.setType(2);
                List<String> constructAuthorizationList = authorizationPictureService.findPictureByItemId(authorizationPictureCompany);
                if (constructAuthorizationList.size() > 0) {
                    projectinfoVO.setConstructAuthorizationList(constructAuthorizationList);
                }
                result = responseSuccess(projectinfoVO);
            } else {
                result = responseFail(ResultCode.MSG_DATA_ISEMPTY);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }

    /**
     * @author chenjian
     * @time 2016年12月22日下午8:31:52
     */
    @ApiOperation(value = "根据承建单位租户编号查询项目列表", notes = "", response = ProjectInfo.class)
    @ApiImplicitParams({@ApiImplicitParam(name = "userCode", value = "租户编号", required = true, dataType = "String", paramType = "path"),
            @ApiImplicitParam(name = "pageNum", value = "分页", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "分页条数", required = true, dataType = "int", paramType = "query")})

    @RequestMapping(value = "/findProjectList/{userCode}", method = RequestMethod.GET)
    public String findProjectListByUserCode(@PathVariable String userCode, @RequestParam int pageNum, @RequestParam int pageSize) throws Exception {
        String result = null;
        if (userCode != null) {
            PageDTO pageDTO = new PageDTO();
            pageDTO.setPageNum(pageNum);
            pageDTO.setPageSize(pageSize);
            Page<ProjectInfo> projectinfoList = projectinfoService.findProjectListByUserCode(pageDTO, userCode);
            if (projectinfoList.size() > 0) {
                result = responseSuccess(projectinfoList);
            } else {
                result = responseFail(ResultCode.MSG_ERROR);
            }
        } else {
            result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }
    
    /**
	 * @Description：查询所有项目名称（陈健）
	 * @Author：chenjian
	 * @Create Date：2017年2月20日
	 * @param：
	 * @return：
	 */
	@ApiOperation(value = "查询所有项目名称（陈健）", notes = "控制台-项目管理-项目基本资料",response=ProjectInfoNameVO.class)
	@RequestMapping(value = "/findProjectNameNoPage/{userCode}/{companyUserCode}", method = RequestMethod.GET, produces = "application/json")
	@ApiImplicitParams({@ApiImplicitParam(name="userCode",value="分包承包人租户编号",required = true, dataType = "String", paramType = "path"),    
						@ApiImplicitParam(name="companyUserCode",value="建筑公司租户编号",required = true, dataType = "String", paramType = "path")})
	public String findProjectNameNoPage(@PathVariable String userCode,@PathVariable String companyUserCode) {
		String result = null;
		if(StringUtils.isNotBlank(userCode)&&StringUtils.isNotBlank(companyUserCode)){
			Map<String,Object> map = new HashMap<>();
			map.put("userCode", userCode);
			map.put("companyUserCode", companyUserCode);
			Page<ProjectInfoNameVO> list = projectinfoService.findProjectNameNoPage(map);
			if (list.size() > 0) {
				result = responseArraySuccess(list);
			} else {
				result = responseFail(ResultCode.FAILED,
						ResultCode.MSG_DATA_ISEMPTY);
			}
		}else{
			result = responseFail(ResultCode.MSG_PARAMS_ERROR);
		}
		return result;
	}
	
	/**
	 * @Description：根据项目名称查询（陈健）
	 * @Author：chenjian
	 * @Create Date：2017年2月20日
	 * @param：
	 * @return：
	 */
	@ApiOperation(value = "根据项目名称查询（陈健）", notes = "控制台-项目管理-项目基本资料")
	@RequestMapping(value = "/findProjectByName/{projectName}", method = RequestMethod.GET, produces = "application/json")
    @ApiImplicitParam(name = "projectName", value = "项目名称", required = true, dataType = "String", paramType = "path")
	public String findProjectByName(@PathVariable String projectName) {
		String result = null;
		Page<ProjectInfoNameVO> list = projectinfoService.findProjectByName(projectName);
		if (list.size() > 0) {
			result = responseSuccess(1);
		} else {
			result = responseSuccess(0);
		}
		return result;
	}
	
	/**
	 * @Description：项目资金管理-根据条件查询项目名称（陈健）
	 * @Author：chenjian
	 * @Create Date：2017年2月20日
	 * @param：
	 * @return：
	 */
	@ApiOperation(value = "项目资金管理-根据条件查询项目名称（陈健）", notes = "控制台-项目管理-项目基本资料",response=ProjectInfoNameVO.class)
	@RequestMapping(value = "/findProjectName/{managerUserCode}/{companyUserCode}", method = RequestMethod.GET, produces = "application/json")
	@ApiImplicitParams({@ApiImplicitParam(name="managerUserCode",value="分包承包人租户编号",required = true, dataType = "String", paramType = "path"),    
						@ApiImplicitParam(name="companyUserCode",value="建筑公司租户编号",required = true, dataType = "String", paramType = "path")})
	public String findProjectName(@PathVariable String managerUserCode,@PathVariable String companyUserCode) {
		String result = null;
		if(StringUtils.isNotBlank(managerUserCode)&&StringUtils.isNotBlank(companyUserCode)){
			Map<String,Object> map = new HashMap<>();
			map.put("managerUserCode", managerUserCode);
			map.put("companyUserCode", companyUserCode);
			Page<ProjectInfoNameVO> list = projectinfoService.findProjectName(map);
			if (list.size() > 0) {
				result = responseArraySuccess(list);
			} else {
				result = responseFail(ResultCode.FAILED,
						ResultCode.MSG_DATA_ISEMPTY);
			}
		}else{
			result = responseFail(ResultCode.MSG_PARAMS_ERROR);
		}
		return result;
	}
	/**
	 * add by juchengyang 2017/3/1
	 */
	@ApiOperation("项目经理发布找工人，查找拥有项目信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "userCode", dataType = "String", required = true, value = "用户code"),
            @ApiImplicitParam(paramType = "query", name = "projectName", dataType = "String", required = false, value = "项目名称")})
    @RequestMapping(value = "/findProjectByUserCodeAndProjectName/{userCode}", method = RequestMethod.GET)
    public String findProjectByUserCodeAndProjectName(@PathVariable String userCode, String projectName) {
        String result = null;
        if (userCode != null && !"".equals(userCode)) {
        	List<projectInfoAppVO> projectInfoList = new ArrayList<>();
        	Map<String, Object> map = new HashMap<>();
        	map.put("userCode", userCode);
        	if (StringUtils.isNotBlank(projectName)){
        		map.put("projectName", projectName);
        	}
            projectInfoList = projectinfoService.findProjectByUserCodeAndProjectName(map);
            result = responseArraySuccess(projectInfoList, ResultCode.SUCCESS, ResultCode.MSG_SUCCESS);
        } else {
        	result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }
	
	/**
	 * @Description：根据项目编号查询开工日期和完工日期（陈健）
	 * @Author：chenjian
	 * @Create Date：2017年3月8日
	 * @param：
	 * @return：
	 */
	@ApiOperation(value="根据项目编号查询开工日期和完工日期（陈健）",response=ProjectStartEndTimeVO.class)
    @ApiImplicitParam(paramType = "path", name = "projectCode", dataType = "String", required = true, value = "项目编号")
    @RequestMapping(value = "/projectStartEndTime/{projectCode}", method = RequestMethod.GET)
    public String findProjectStartEndTime(@PathVariable String projectCode) {
        String result = null;
        if (StringUtils.isNotBlank(projectCode)) {
            List<ProjectStartEndTimeVO> list = projectinfoService.findProjectStartEndTime(projectCode);
            result = responseArraySuccess(list, ResultCode.SUCCESS, ResultCode.MSG_SUCCESS);
        } else {
        	result = responseFail(ResultCode.MSG_PARAMS_NULL);
        }
        return result;
    }
	
}

